Skip to content

Add native AI Credits parsing helpers#135

Merged
asizikov merged 2 commits into
mainfrom
asizikov/native-ai-credits-parsing-tests
Jun 5, 2026
Merged

Add native AI Credits parsing helpers#135
asizikov merged 2 commits into
mainfrom
asizikov/native-ai-credits-parsing-tests

Conversation

@asizikov

@asizikov asizikov commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

Native AI Credits report support needs parser-level groundwork without changing the live upload behavior. This PR adds focused native parsing helpers and tests while keeping native reports rejected by the upload pipeline until UI and aggregation support are ready.

Commit Change
feat: add native AI Credits parsing helpers Adds native parser helpers, date normalization, and safety tests proving native uploads still stop before aggregation
fix: keep native AI Credits fields authoritative Addresses review feedback by keeping native quantity, gross, and net fields as the source of truth for AIC aliases

Changes

  • Adds a native AI Credits date normalizer that converts slash-form export dates like 5/29/26 to ISO dates such as 2026-05-29.
  • Adds an explicit native AI Credits row parsing helper that keeps native quantity, gross_amount, discount_amount, and net_amount as the usage and cost fields, while exposing those values through AIC alias fields for compatibility.
  • Addresses review feedback so native AIC aliases do not prefer divergent alias columns and aic_net_amount preserves native discounts from net_amount.
  • Strengthens pipeline coverage so native reports still throw UnsupportedNativeAiCreditsReportError before aggregator headers or rows are processed.
  • Leaves the native adapter unsupported and does not wire native parsing into upload processing.

Testing

  • npm test
  • npm run lint
  • npm run build

Checklist

  • Specs lint passes (npm run lint)
  • Tests updated if applicable
  • Documentation updated if applicable (N/A)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 5, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR lays groundwork for supporting “native” AI Credits billing exports by adding parser-level helpers and tests, while ensuring the upload pipeline still rejects native AI Credits reports before any aggregation occurs.

Changes:

  • Added a native AI Credits date normalization helper to convert slash-form dates (e.g., 5/29/26) into ISO format.
  • Added a native AI Credits row parsing helper and accompanying unit tests.
  • Updated pipeline tests to assert native AI Credits reports fail fast with UnsupportedNativeAiCreditsReportError and do not invoke aggregator hooks.
Show a summary per file
File Description
src/pipeline/runPipeline.test.ts Strengthens regression coverage that native AI Credits uploads are rejected before any aggregation processing begins.
src/pipeline/parser.ts Introduces native AI Credits parsing/date normalization helpers for future integration.
src/pipeline/parser.test.ts Adds test coverage for the new native helper behavior (date normalization + alias/fallback behavior).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread src/pipeline/parser.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asizikov
asizikov merged commit 7f5a5d6 into main Jun 5, 2026
9 checks passed
@asizikov
asizikov deleted the asizikov/native-ai-credits-parsing-tests branch June 5, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants